package com.tbit.main.service.impl;

import com.tbit.main.pojo.Machine;
import com.tbit.main.pojo.OrderLog;
import com.tbit.main.service.*;
import com.tbit.main.util.DateTimeUtil;
import com.tbit.main.util.LogUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author LMY
 * @create 2022-09-19 15:00
 */
@Service
public class MachineQuartzServiceImpl implements MachineQuartzService {

    @Autowired
    private DataServiceImpl dataService;
    @Autowired
    private MachineStatusService machineStatusService;
    @Autowired
    private AccountConfigExtService accountConfigExtService;
    @Autowired
    private TerControlService terControlService;
    @Autowired
    private OrderLogService orderLogService;
    @Autowired
    private RedisService redisService;
    @Autowired
    private ParkService parkService;

    /***
     * 添加远程指令日志
     * @param machine
     * @param serNo
     * @param orderContent
     * @param remark
     */
    public void setOrderLog(Machine machine, String serNo, String orderContent, String remark) {
        LogUtil.info("[" + machine.getMachineNO() + "]" + remark);

        /**远程指令日志*/
        OrderLog orderLog = new OrderLog();
        orderLog.setMachineId(machine.getMachineId());
        orderLog.setMachineNo(machine.getMachineNO());
        orderLog.setUserCode(machine.getUserCode());
        orderLog.setOpType(0);
        orderLog.setOpId(0);
        orderLog.setAccountUserId(0);
        orderLog.setOpTime(DateTimeUtil.getNowTime());
        orderLog.setChannelType(0);
        orderLog.setBusinessType(1);
        orderLog.setOrderType("0");
        orderLog.setOrderSerNo(serNo);
        orderLog.setOrderSource(8);
        orderLog.setOrderContent(orderContent);
        orderLog.setRemark(remark);
        orderLogService.insert(orderLog);
    }
}
